home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: news.sprintlink.net!news1!ind-005-236-220
- From: dlmiller@iquest.net (Doug Miller)
- Subject: Re: Determining the length of an int in string form
- X-Nntp-Posting-Host: ind-005-236-220.iquest.net
- Message-ID: <DoGs5D.FFB@iquest.net>
- Sender: news@iquest.net (News Admin)
- Organization: IQuest Network Services
- X-Newsreader: News Xpress Version 1.0 Beta #2.1
- References: <3146D058.DD7@cbm.com> <4i7uth$qph@inet-nntp-gw-1.us.oracle.com> <DoE38u.GIH@iquest.net>
- Date: Mon, 18 Mar 1996 13:03:05 GMT
-
- dlmiller@iquest.net (Doug & Rose Miller) wrote:
- +Xref: news1 comp.lang.c:70898
- +Newsgroups: comp.lang.c
- +Path: news1!ts02-and-07
- +From: dlmiller@iquest.net (Doug & Rose Miller)
- +Subject: Re: Determining the length of an int in string form
- +X-Nntp-Posting-Host: ts02-and-07.iquest.net
- +Message-ID: <DoE38u.GIH@iquest.net>
- +Sender: news@iquest.net (News Admin)
- +Organization: IQuest Network Services
- +X-Newsreader: News Xpress Version 1.0 Beta #2.1
- +References: <3146D058.DD7@cbm.com> <4i7uth$qph@inet-nntp-gw-1.us.oracle.com>
- +Date: Sun, 17 Mar 1996 02:02:28 GMT
- +Lines: 14
- +
- +wkaufman@wkaufman.us.oracle.com (William Kaufman) wrote:
- ++In article <3146D058.DD7@cbm.com> Dave Payne <paynedc@cbm.com> writes:
- ++] Consider this:
- ++]
- ++] I have a variable of type int, and I would like to use the sprintf()
- ++] function to write this variable to a string. However, I want to
- ++] dynamically allocate the space for the string, and only malloc enough
- ++] space to hold the int.
- +
- +WHY ???
- +
- +Even a 32-bit int is only 9 characters at most, and that's *with* the sign. Why not just declare
- +a string and be done with it? Is storage space that tight for you, that nine bytes matters?
- +
- Oops! make that 11 characters with sign -- sorry about that. But my point remains.
- Even if an int is 64 bits wide, what's the big deal? Why the burning need for dynamic allocation
- of only ten or twenty bytes?
-